package schedulo.gui.components;

import javax.swing.ButtonGroup;
import javax.swing.JPanel;

import schedulo.core.task.provider.TaskProvider;
import schedulo.core.task.provider.TaskProviderFactoryListener;
import schedulo.core.task.provider.TaskProviderListener;

import java.awt.Component;
import java.awt.Dimension;
import java.awt.GridBagLayout;
import javax.swing.JLabel;
import java.awt.GridBagConstraints;
import javax.swing.JComboBox;
import java.awt.Insets;
import javax.swing.BorderFactory;
import javax.swing.border.TitledBorder;
import javax.swing.JRadioButton;
import javax.swing.JButton;

public class TimeTrackerPanel extends JPanel implements TaskProviderFactoryListener, TaskProviderListener {

	
	
	private JLabel labelTaskList = null;
	private JComboBox jComboBox = null;
	private JLabel labelTask = null;
	private JPanel jPanel = null;
	private JComboBox jComboBox1 = null;
	private JRadioButton radioButtonExisting = null;
	private JRadioButton radioButtonNew = null;
	private JPanel jPanel1 = null;
	private NewTaskPanel newTaskPanel;  //  @jve:decl-index=0:
	private JButton buttonStart = null;
	private JButton buttonStop = null;
	private JButton buttonCancel = null;
	private JLabel jLabel = null;

	/**
	 * This method initializes 
	 * 
	 */
	public TimeTrackerPanel() {
		super();
		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 */
	private void initialize() {
        GridBagConstraints gridBagConstraints15 = new GridBagConstraints();
        gridBagConstraints15.gridx = 1;
        gridBagConstraints15.weightx = 1.0D;
        gridBagConstraints15.gridy = 6;
        jLabel = new JLabel();
        jLabel.setText("");
        GridBagConstraints gridBagConstraints14 = new GridBagConstraints();
        gridBagConstraints14.gridx = 4;
        gridBagConstraints14.insets = new Insets(5, 5, 5, 5);
        gridBagConstraints14.gridy = 6;
        GridBagConstraints gridBagConstraints13 = new GridBagConstraints();
        gridBagConstraints13.gridx = 3;
        gridBagConstraints13.insets = new Insets(5, 5, 5, 5);
        gridBagConstraints13.gridy = 6;
        GridBagConstraints gridBagConstraints12 = new GridBagConstraints();
        gridBagConstraints12.fill = GridBagConstraints.BOTH;
        gridBagConstraints12.gridx = 0;
        gridBagConstraints12.gridy = 1;
        gridBagConstraints12.insets = new Insets(5, 5, 5, 5);
        GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
        gridBagConstraints11.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints11.gridx = 1;
        gridBagConstraints11.gridy = 1;
        gridBagConstraints11.weightx = 0.0D;
        gridBagConstraints11.gridwidth = 4;
        gridBagConstraints11.insets = new Insets(10, 5, 5, 5);
        GridBagConstraints gridBagConstraints6 = new GridBagConstraints();
        gridBagConstraints6.gridx = 0;
        gridBagConstraints6.fill = GridBagConstraints.BOTH;
        gridBagConstraints6.insets = new Insets(5, 20, 5, 5);
        gridBagConstraints6.gridwidth = 5;
        gridBagConstraints6.gridy = 5;
        GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
        gridBagConstraints5.gridx = 0;
        gridBagConstraints5.anchor = GridBagConstraints.NORTHWEST;
        gridBagConstraints5.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints5.insets = new Insets(10, 0, 0, 0);
        gridBagConstraints5.gridwidth = 5;
        gridBagConstraints5.gridy = 4;
        GridBagConstraints gridBagConstraints41 = new GridBagConstraints();
        gridBagConstraints41.gridx = 0;
        gridBagConstraints41.anchor = GridBagConstraints.NORTHWEST;
        gridBagConstraints41.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints41.weightx = 0.0D;
        gridBagConstraints41.insets = new Insets(10, 0, 0, 0);
        gridBagConstraints41.gridwidth = 5;
        gridBagConstraints41.gridy = 2;
        GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
        gridBagConstraints3.gridx = 0;
        gridBagConstraints3.insets = new Insets(5, 20, 5, 5);
        gridBagConstraints3.fill = GridBagConstraints.BOTH;
        gridBagConstraints3.weightx = 1.0D;
        gridBagConstraints3.weighty = 0.0D;
        gridBagConstraints3.gridwidth = 5;
        gridBagConstraints3.gridy = 3;
        labelTask = new JLabel();
        labelTask.setText("Task");
        GridBagConstraints gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.insets = new Insets(5, 5, 5, 5);
        gridBagConstraints.fill = GridBagConstraints.NONE;
        gridBagConstraints.gridy = 6;
        labelTaskList = new JLabel();
        labelTaskList.setText("Task list");
        this.setLayout(new GridBagLayout());
        this.setSize(new Dimension(481, 470));
        this.add(getJPanel(), gridBagConstraints3);
        this.add(getRadioButtonExisting(), gridBagConstraints41);
        this.add(getRadioButtonNew(), gridBagConstraints5);
        this.add(getJPanel1(), gridBagConstraints6);
        this.add(getJComboBox(), gridBagConstraints11);
        this.add(labelTaskList, gridBagConstraints12);
        this.add(getButtonStart(), gridBagConstraints);
        this.add(getButtonStop(), gridBagConstraints13);
        this.add(getButtonCancel(), gridBagConstraints14);
        this.add(jLabel, gridBagConstraints15);
        
        ButtonGroup bg = new ButtonGroup();
        bg.add(getRadioButtonExisting());
        bg.add(getRadioButtonNew());
			
	}

	public void taskProviderAdded(TaskProvider taskProvider) {
		// TODO Auto-generated method stub
		
	}

	public void taskProviderRemoved(TaskProvider taskProvider) {
		// TODO Auto-generated method stub
		
	}

	public void taskProviderUpdated(TaskProvider taskProvider) {
		// TODO Auto-generated method stub
		
	}

	/**
	 * This method initializes jComboBox	
	 * 	
	 * @return javax.swing.JComboBox	
	 */
	private JComboBox getJComboBox() {
		if (jComboBox == null) {
			jComboBox = new JComboBox();
		}
		return jComboBox;
	}

	/**
	 * This method initializes jPanel	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getJPanel() {
		if (jPanel == null) {
			GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
			gridBagConstraints4.fill = GridBagConstraints.BOTH;
			gridBagConstraints4.gridy = 1;
			gridBagConstraints4.weightx = 1.0;
			gridBagConstraints4.insets = new Insets(5, 5, 5, 5);
			gridBagConstraints4.gridx = 1;
			GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
			gridBagConstraints2.gridx = 0;
			gridBagConstraints2.fill = GridBagConstraints.BOTH;
			gridBagConstraints2.insets = new Insets(5, 5, 5, 5);
			gridBagConstraints2.gridy = 1;
			
			
			jPanel = new JPanel();
			jPanel.setLayout(new GridBagLayout());
			jPanel.setBorder(BorderFactory.createTitledBorder(null, "Existing task", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
			jPanel.add(labelTask, gridBagConstraints2);
			jPanel.add(getJComboBox1(), gridBagConstraints4);
		}
		return jPanel;
	}

	/**
	 * This method initializes jComboBox1	
	 * 	
	 * @return javax.swing.JComboBox	
	 */
	private JComboBox getJComboBox1() {
		if (jComboBox1 == null) {
			jComboBox1 = new JComboBox();
		}
		return jComboBox1;
	}

	/**
	 * This method initializes radioButtonExisting	
	 * 	
	 * @return javax.swing.JRadioButton	
	 */
	private JRadioButton getRadioButtonExisting() {
		if (radioButtonExisting == null) {
			radioButtonExisting = new JRadioButton();
		}
		return radioButtonExisting;
	}

	/**
	 * This method initializes radioButtonNew	
	 * 	
	 * @return javax.swing.JRadioButton	
	 */
	private JRadioButton getRadioButtonNew() {
		if (radioButtonNew == null) {
			radioButtonNew = new JRadioButton();
		}
		return radioButtonNew;
	}

	/**
	 * This method initializes jPanel1	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getJPanel1() {
		if (jPanel1 == null) {
			GridBagConstraints gridBagConstraints7 = new GridBagConstraints();
			gridBagConstraints7.gridx = 2;
			gridBagConstraints7.insets = new Insets(5, 5, 5, 5);
			gridBagConstraints7.gridy = 6;
			jPanel1 = new JPanel();
			jPanel1.setLayout(new GridBagLayout());
			jPanel1.setBorder(BorderFactory.createTitledBorder(null, "New task", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
			GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
			gridBagConstraints1.fill = GridBagConstraints.BOTH;
			gridBagConstraints1.gridx = 0;
			gridBagConstraints1.gridy = 0;
			gridBagConstraints1.weightx = 1.0D;
			gridBagConstraints1.insets = new Insets(10, 5, 5, 5);
			jPanel1.add(getNewTaskPanel(), gridBagConstraints1);
		}
		return jPanel1;
	}

	private NewTaskPanel getNewTaskPanel() {
		if(newTaskPanel == null) {
			newTaskPanel = new NewTaskPanel();
		}
		return newTaskPanel;
	}

	/**
	 * This method initializes buttonStart	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getButtonStart() {
		if (buttonStart == null) {
			buttonStart = new JButton();
			buttonStart.setText("Start");
			buttonStart.setEnabled(false);
		}
		return buttonStart;
	}

	/**
	 * This method initializes buttonStop	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getButtonStop() {
		if (buttonStop == null) {
			buttonStop = new JButton();
			buttonStop.setText("Stop");
			buttonStop.setEnabled(false);
		}
		return buttonStop;
	}

	/**
	 * This method initializes buttonCancel	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getButtonCancel() {
		if (buttonCancel == null) {
			buttonCancel = new JButton();
			buttonCancel.setText("Cancel");
			buttonCancel.setEnabled(false);
		}
		return buttonCancel;
	}

}  //  @jve:decl-index=0:visual-constraint="13,2"
